package com.tiza.xiaoyoubao.ui.fragment;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.view.View;

import com.tianze.library.base.BaseFragment;
import com.tiza.xiaoyoubao.R;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * Created by mapple on 17/2/17.
 * 我的消息
 */

public class MyNewsFragment extends BaseFragment {
    @BindView(R.id.view_system_news)
    View view_system_news;
    @BindView(R.id.view_user_news)
    View view_user_news;
    private static FragmentManager fm ;
    @Override
    protected int getLayoutId() {
        return R.layout.fragment_mynews_layout;
    }

    @Override
    protected void initData() {
    }

    @Override
    protected void initView() {
        setToolbarTitle("我的消息");
        fm=getFragmentManager();
        showFragment(new SystemNewsFragment());
    }

    @OnClick({R.id.view_system_news,R.id.view_user_news})
    public void onClick(View view){
        switch (view.getId()){
            case R.id.view_system_news:
                view_system_news.setBackgroundResource(R.color.dodger_blue);
                view_user_news.setBackgroundResource(R.color.steel_blue);
                showFragment(new SystemNewsFragment());
                break;
            case R.id.view_user_news:
                view_user_news.setBackgroundResource(R.color.dodger_blue);
                view_system_news.setBackgroundResource(R.color.steel_blue);
                showFragment(new UserNewsFragment());
                break;
        }

    }
    public static void showFragment(Fragment fragment) {
        FragmentTransaction transaction = fm.beginTransaction();
        transaction.replace(R.id.fl_content, fragment);
        transaction.commit();

    }
}
